public class SolutionLCP68 {
    public int beautifulBouquet(int[] flowers, int cnt) {
        int[] f=new int[100005];
        int t=0;
        while (t<flowers.length){
            if (f[flowers[t]]==cnt){
                break;
            }
            f[flowers[t]]++;
            t++;
        }
        long ans=t;
        for (int i=0;i<flowers.length;i++){
            f[flowers[i]]--;
            while (t<flowers.length){
                if (f[flowers[t]]==cnt){
                    break;
                }
                f[flowers[t]]++;
                t++;
            }
            ans=(ans+(t-i-1))%1000000007;
        }
        return (int)ans;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionLCP68().beautifulBouquet(new int[]{1,2,3,2},1));
    }
}
